﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ModelConfigurator
{
    public partial class FormParams : FormBase
    {
        /// <summary>
        /// Список параметров
        /// </summary>
        public List<string> ParamNames{get; set;}

        public FormParams()
        {
            InitializeComponent();
        }

        private void FormParams_Load(object sender, EventArgs e)
        {
            int i = 0;
            foreach (string s in ParamNames)
            {
                dataGridViewParam.Rows.Add();
                dataGridViewParam[0, i++].Value = s;
            }
        }

        private void dataGridViewParam_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int i = e.RowIndex;
            string s = dataGridViewParam[0, i].Value as string;
            if (s == null)
                ParamNames[i] = "";
            else
                ParamNames[i] = s;
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        private void buttonHelp_Click(object sender, EventArgs e)
        {
            string openCHMFile = Application.StartupPath + "\\Справка SAPR-SIM.chm";
            try
            {
                if (!System.IO.File.Exists(openCHMFile))
                    System.IO.File.WriteAllBytes(openCHMFile, global::ModelConfigurator.Properties.Resources.Справка_SAPR_SIM);
            }
            catch
            {
                //если файл есть он не перепишется
            }
            helpProvider1.HelpNamespace = openCHMFile;
            Help.ShowHelp(this, this.helpProvider1.HelpNamespace, HelpNavigator.Topic, "module_2_6.htm");
        }
    }
}
